/*
package com.microorganism.platform.controller.upload;

import com.veeker.log.annotations.Log;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

*/
/**
 * @author ：qiaoliang
 * @date ：2020-11-11
 *//*

@Api(tags = "上传图片管理")
@RequestMapping("/upload")
@RestController
public class UploadController {

    @Value("${spring.path}")
    private String dirPath;

    @Log(businessType = "上传图片管理",discription = "上传图片")
    @ApiOperation(value = "上传图片")
    @PostMapping("/image")
    public ResponseEntity<?> uoloadFile(@RequestParam("file") MultipartFile file) throws IOException {
        // 获取文件名，带后缀
        String originalFilename = file.getOriginalFilename();
        // 只有当满足图片格式时才进来，重新赋图片名，防止出现名称重复的情况
        String newFileName = UUID.randomUUID() + originalFilename + ".jpg";
        // 该方法返回的为当前项目的工作目录，即在哪个地方启动的java线程
        String path = File.separator + "uploadImg" + File.separator + newFileName;
        File destFile = new File(dirPath + path);
        if (!destFile.getParentFile().exists()) {
            destFile.getParentFile().mkdirs();
        }
        file.transferTo(destFile);
        // 将相对路径返回给前端
        return ResponseEntity.status(HttpStatus.CREATED).body(path);
    }

}
*/
